#cat ~/.data/cosmic/lists/save/2011*/newcheck/0*Trun.log > listrun.log

run=$1
tag=$2
dir=$3
outdir=$4/all$tag

echo $run $tag $dir $outdir

file=$(find $(pwd)/$dir/2*/*$tag\_11000$run*.root)

#echo $file

#find $outdir

#exit 

if [ ${#file} -gt 0 ]
then
    echo merging $run $tag
    hadd $outdir/run$run$tag.root $file > $outdir/see$run$tag.log
else
    echo missing $run $tag
fi

